<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.OAP;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.OAP">
		<cfargument name="OAP_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.OAP_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new OAP();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new OAP();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.OAP">
		<cfargument name="obj" type="assets.calgrants.com.bo.OAP" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.OAP_ID")) {
				local.obj.setOAP_ID(arguments.OAP_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Organization_ID")) {
				local.obj.setOrganization_ID(arguments.Organization_ID); 
			}
			if (IsDefined("arguments.Created_By_ID")) {
				local.obj.setCreated_By_ID(arguments.Created_By_ID);
			}
			if (IsDefined("arguments.Program_Year")) {
				local.obj.setProgram_Year(arguments.Program_Year);
			}
			if (IsDefined("arguments.Workshop_Count")) {
				local.obj.setWorkshop_Count(arguments.Workshop_Count);
			}
			if (IsDefined("arguments.Student_Target")) {
				local.obj.setStudent_Target(arguments.Student_Target);
			}
			if (IsDefined("arguments.OAP_Value_IDs")) {
				local.obj.setOAP_Value_IDs(arguments.OAP_Value_IDs);
			}	
			if (IsDefined("arguments.Campus_Other")) {
				local.obj.setCampus_Other(arguments.Campus_Other);
			}	
			if (IsDefined("arguments.Parent_Other")) {
				local.obj.setParent_Other(arguments.Parent_Other);
			}	
			if (IsDefined("arguments.Community_Partner_Other")) {
				local.obj.setCommunity_Partner_Other(arguments.Community_Partner_Other);
			}	
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}		
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="OAP_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Created_By_ID" required="false" default="" />
		<cfargument name="Program_Year" required="false" default="" />
		<cfargument name="Workshop_Count" required="false" default="" />
		<cfargument name="Student_Target" required="false" default="" />
		<cfargument name="OAP_Value_IDs" required="false" default="" />
		<cfargument name="Campus_Other" required="false" default="" />
		<cfargument name="Parent_Other" required="false" default="" />
		<cfargument name="Community_Partner_Other" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readOAP">
			<cfprocparam value="#arguments.OAP_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.OAP_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organization_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Created_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Created_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Program_Year#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Program_Year)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Workshop_Count#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Workshop_Count)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Student_Target#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Student_Target)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.OAP_Value_IDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.OAP_Value_IDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Campus_Other#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Campus_Other)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Parent_Other#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Parent_Other)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Community_Partner_Other#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Community_Partner_Other)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="oap" required="true" type="assets.calgrants.com.bo.OAP" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveOAP">
			<cfprocparam value="#oap.getOAP_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#oap.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#oap.getOrganization_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#oap.getCreated_By_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#oap.getProgram_Year()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#oap.getWorkshop_Count()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#oap.getStudent_Target()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#oap.getOAP_Value_IDs()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#oap.getCampus_Other()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(oap.getCampus_Other())) eq 0, true, false)#" />
			<cfprocparam value="#oap.getParent_Other()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(oap.getParent_Other())) eq 0, true, false)#" />
			<cfprocparam value="#oap.getCommunity_Partner_Other()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(oap.getCommunity_Partner_Other())) eq 0, true, false)#" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="OAP_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyOAP">
			<cfprocparam value="#arguments.OAP_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

